import leancloud


def save_to_lean(lean_dic, lean_module_name):
    if not isinstance(lean_dic, dict) or not lean_module_name:
        raise Exception('保存到LEAN CLOUD 失败')
    LeanModel = leancloud.Object.extend(lean_module_name)
    lean_model = LeanModel()
    for key, value in lean_dic.items():
        lean_model.set(key, value)
    lean_model.save()


